# define RE_SYNTAX_EMACS 0

# define RE_SYNTAX_AWK\
  (RE_BACKSLASH_ESCAPE_IN_LISTS   | RE_DOT_NOT_NULL\
   | RE_NO_BK_PARENS              | RE_NO_BK_REFS\
   | RE_NO_BK_VBAR                | RE_NO_EMPTY_RANGES\
   | RE_DOT_NEWLINE  | RE_CONTEXT_INDEP_ANCHORS\
   | RE_CHAR_CLASSES\
   | RE_UNMATCHED_RIGHT_PAREN_ORD | RE_NO_GNU_OPS)

# define RE_SYNTAX_GNU_AWK\
  ((RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS\
    | RE_INVALID_INTERVAL_ORD)\
   & ~(RE_DOT_NOT_NULL | RE_CONTEXT_INDEP_OPS\
      | RE_CONTEXT_INVALID_OPS ))

# define RE_SYNTAX_POSIX_AWK\
  (RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS\
   | RE_INTERVALS    | RE_NO_GNU_OPS\
   | RE_INVALID_INTERVAL_ORD)

# define RE_SYNTAX_GREP\
  ((RE_SYNTAX_POSIX_BASIC | RE_NEWLINE_ALT)\
   & ~(RE_CONTEXT_INVALID_DUP | RE_DOT_NOT_NULL))

# define RE_SYNTAX_EGREP\
  ((RE_SYNTAX_POSIX_EXTENDED | RE_INVALID_INTERVAL_ORD | RE_NEWLINE_ALT) \
   & ~(RE_CONTEXT_INVALID_OPS | RE_DOT_NOT_NULL))

/* POSIX grep 的-E参数不再与GNU兼容  */
# define RE_SYNTAX_POSIX_EGREP\
  RE_SYNTAX_EGREP

/* P1003.2/D11.2, section 4.20.7.1, 5078ff行.  */
# define RE_SYNTAX_ED RE_SYNTAX_POSIX_BASIC

# define RE_SYNTAX_SED RE_SYNTAX_POSIX_BASIC

/* POSIX基础和扩展语法的共用语法.  */
# define _RE_SYNTAX_POSIX_COMMON\
  (RE_CHAR_CLASSES | RE_DOT_NEWLINE      | RE_DOT_NOT_NULL\
   | RE_INTERVALS  | RE_NO_EMPTY_RANGES)

# define RE_SYNTAX_POSIX_BASIC\
  (_RE_SYNTAX_POSIX_COMMON | RE_BK_PLUS_QM | RE_CONTEXT_INVALID_DUP)

/* 与..._POSIX_BASIC的唯一不同是将RE_BK_PLUS_QM变更为
   RE_LIMITED_OPS, 也就是说, 无法识别\? \+ \|。
     实际上，这并不是最小语法，因为并未禁用类似\'的其它运算符。*/
# define RE_SYNTAX_POSIX_MINIMAL_BASIC\
  (_RE_SYNTAX_POSIX_COMMON | RE_LIMITED_OPS)

# define RE_SYNTAX_POSIX_EXTENDED\
  (_RE_SYNTAX_POSIX_COMMON  | RE_CONTEXT_INDEP_ANCHORS\
   | RE_CONTEXT_INDEP_OPS   | RE_NO_BK_BRACES\
   | RE_NO_BK_PARENS        | RE_NO_BK_VBAR\
   | RE_CONTEXT_INVALID_OPS | RE_UNMATCHED_RIGHT_PAREN_ORD)

/* 与..._POSIX_EXTENDED的不同在于移除了RE_CONTEXT_INDEP_OPS，
   并添加了RE_NO_BK_REFS  */
# define RE_SYNTAX_POSIX_MINIMAL_EXTENDED\
  (_RE_SYNTAX_POSIX_COMMON  | RE_CONTEXT_INDEP_ANCHORS\
   | RE_CONTEXT_INVALID_OPS | RE_NO_BK_BRACES\
   | RE_NO_BK_PARENS        | RE_NO_BK_REFS\
   | RE_NO_BK_VBAR    | RE_UNMATCHED_RIGHT_PAREN_ORD)
